home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
CU Amiga Super CD-ROM 11
/
CU Amiga Magazine's Super CD-ROM 11 (1997)(EMAP Images)(GB)(Track 1 of 3)[!][issue 1997-06].iso
/
cucd
/
programming
/
oberonv4
/
source
/
system
/
backup.mod
(
.txt
)
< prev
next >
Wrap
Oberon Text
|
1994-06-23
|
5KB
|
149 lines
Syntax10.Scn.Fnt
Syntax10i.Scn.Fnt
Syntax10b.Scn.Fnt
MODULE Backup; (*JG 30.1.93, MP 30.1.94 *)
IMPORT SYSTEM, Diskette, Oberon, Texts, Viewers, MenuViewers, TextFrames;
CONST StandardMenu = "System.Close System.Copy System.Grow Edit.Search Edit.Store";
VAR W: Texts.Writer; diroption: CHAR;
PROCEDURE Format*;
BEGIN
Texts.WriteString(W, "Backup.Format"); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.Format; Diskette.InitDir; Diskette.WriteDir
END Format;
PROCEDURE Init*;
BEGIN
Texts.WriteString(W, "Backup.Init"); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.InitDir; Diskette.WriteDir
END Init;
PROCEDURE SetDrive*; (* MP *)
VAR par: Oberon.ParList; R:Texts.Reader;
ch:CHAR;
BEGIN
par := Oberon.Par;
Texts.OpenReader(R, par.text, par.pos); REPEAT Texts.Read(R,ch) UNTIL ch#" ";
Texts.WriteString(W, "Backup.SetDrive "); Texts.Write(W,ch); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.SetDrive(ORD(ch)-ORD("0"));
END SetDrive;
PROCEDURE List (name: ARRAY OF CHAR; date, time: LONGINT; size: LONGINT);
BEGIN
Texts.WriteString(W, name);
IF diroption = "d" THEN
Texts.WriteDate(W, time, date); Texts.Write(W, " "); Texts.WriteInt(W, size, 1)
END;
Texts.WriteLn(W)
END List;
PROCEDURE Directory*;
VAR par: Oberon.ParList; T: Texts.Text; R: Texts.Reader; V: Viewers.Viewer;
date, time: LONGINT; nofEntries, nofClusters, X, Y: INTEGER; ch: CHAR;
BEGIN
par := Oberon.Par;
Texts.OpenReader(R, par.text, par.pos); Texts.Read(R, ch);
WHILE ch = " " DO Texts.Read(R, ch) END;
IF ch = "/" THEN Texts.Read(R, diroption) ELSE diroption := 0X END;
Diskette.ReadDir;
Diskette.GetData(date, time, nofEntries, nofClusters);
Texts.WriteInt(W, nofEntries, 1); Texts.WriteString(W, " entries/ ");
Texts.WriteInt(W, nofClusters, 1); Texts.WriteString(W, " clusters");
Texts.WriteLn(W);
Diskette.Enumerate(List);
T := TextFrames.Text("");
Texts.Append(T, W.buf);
Oberon.AllocateSystemViewer(Oberon.Par.vwr.X, X, Y);
V := MenuViewers.New(
TextFrames.NewMenu("Backup.Directory", StandardMenu),
TextFrames.NewText(T, 0),
TextFrames.menuH,
X, Y)
END Directory;
PROCEDURE Read (name: ARRAY OF CHAR; date, time: LONGINT; size: LONGINT);
BEGIN
Texts.WriteString(W, name); Texts.WriteString(W, " reading");
Texts.Append(Oberon.Log, W.buf);
Diskette.ReadFile(name);
IF Diskette.res # 0 THEN Texts.WriteString(W, " failed") END;
Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END Read;
PROCEDURE ReadAll*;
BEGIN
Texts.WriteString(W, "Backup.ReadAll"); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.ReadDir; Diskette.Enumerate(Read)
END ReadAll;
PROCEDURE ReadFiles*;
VAR par: Oberon.ParList; S: Texts.Scanner; T: Texts.Text;
beg, end, time: LONGINT;
BEGIN
par := Oberon.Par;
Texts.WriteString(W, "Backup.ReadFiles"); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.ReadDir;
par := Oberon.Par;
Texts.OpenScanner(S, par.text, par.pos); Texts.Scan(S);
WHILE S.class = Texts.Name DO Read(S.s, 0, 0, 0); Texts.Scan(S) END;
IF (S.class = Texts.Char) & (S.c = "^") THEN
Oberon.GetSelection(T, beg, end, time);
IF time >= 0 THEN Texts.OpenScanner(S, T, beg); Texts.Scan(S);
IF S.class = Texts.Name THEN Read(S.s, 0, 0, 0) END
END
END
END ReadFiles;
PROCEDURE WriteFile (VAR name: ARRAY OF CHAR);
BEGIN
Texts.WriteString(W, name); Texts.WriteString(W, " writing");
Texts.Append(Oberon.Log, W.buf);
Diskette.WriteFile(name);
IF Diskette.res # 0 THEN Texts.WriteString(W, " failed") END;
Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END WriteFile;
PROCEDURE WriteFiles*;
VAR par: Oberon.ParList; S: Texts.Scanner; T: Texts.Text; beg,end,time: LONGINT;
BEGIN
par := Oberon.Par;
Texts.WriteString(W, "Backup.WriteFiles"); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.ReadDir;
Texts.OpenScanner(S, par.text, par.pos); Texts.Scan(S);
WHILE S.class = Texts.Name DO WriteFile(S.s); Texts.Scan(S) END;
IF (S.class = Texts.Char) & (S.c = "^") THEN
Oberon.GetSelection(T,beg,end,time);
IF time >= 0 THEN Texts.OpenScanner(S, T, beg); Texts.Scan(S);
IF S.class = Texts.Name THEN WriteFile(S.s) END
END
END;
Diskette.WriteDir
END WriteFiles;
PROCEDURE DeleteFile (VAR name: ARRAY OF CHAR);
BEGIN
Texts.WriteString(W, name); Texts.WriteString(W, " deleting");
Texts.Append(Oberon.Log, W.buf);
Diskette.DeleteFile(name);
IF Diskette.res # 0 THEN Texts.WriteString(W, " failed") END;
Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf)
END DeleteFile;
PROCEDURE DeleteFiles*;
VAR par: Oberon.ParList; T: Texts.Text; S: Texts.Scanner;
beg, end, time: LONGINT;
BEGIN
par := Oberon.Par;
Texts.WriteString(W, "Backup.DeleteFiles"); Texts.WriteLn(W);
Texts.Append(Oberon.Log, W.buf);
Diskette.ReadDir;
Texts.OpenScanner(S, par.text, par.pos); Texts.Scan(S);
WHILE S.class = Texts.Name DO DeleteFile(S.s); Texts.Scan(S) END;
IF (S.class = Texts.Char) & (S.c = "^") THEN
Oberon.GetSelection(T, beg, end, time);
IF time >= 0 THEN Texts.OpenScanner(S, T, beg); Texts.Scan(S);
IF S.class = Texts.Name THEN DeleteFile(S.s) END
END
END;
Diskette.WriteDir
END DeleteFiles;
BEGIN Texts.OpenWriter(W); Diskette.Reset
END Backup.